package com.zz.ecommerce.common;


import org.apache.ibatis.session.RowBounds;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <公共Service层>
 * <已实现基本操作：增-删-改-查[单个对象，列表查询，分页查询>
 *
 * @author Administrator
 * @date 2015/9/3，16:54
 */
@Service
public class CommonBaseService {

    @Autowired
    private CommonBaseDao commonBaseDao;

    public String getSequence(){ return (String)commonBaseDao.commonObject("common.getSequence",null);}

    public <T> int commonInsert(String sqlId, T params) {
        return commonBaseDao.commonInsert(sqlId, params);
    }

    public <T> int commonDelete(String sqlId, T params) {
        return commonBaseDao.commonDelete(sqlId, params);
    }

    public <T> int commonUpdate(String sqlId, T params) {
        return commonBaseDao.commonUpdate(sqlId, params);
    }

    public <T> Object commonObject(String sqlId, T params) {
        return commonBaseDao.commonObject(sqlId, params);
    }

    public <T, E> List<T> commonList(String sqlId, E params) {
        return commonBaseDao.commonList(sqlId, params);
    }

    public <T, E extends GridRequest> List<T> commonPaginationList(String sqlId, String sqlCountId, E params) {
        return commonBaseDao.commonPaginationList(sqlId,sqlCountId, params);
    }

    public <T, E> List<T> commonPaginationList(String sqlId, E params,RowBounds rowBounds) {
        return commonBaseDao.commonPaginationList(sqlId, params, rowBounds);
    }
}
